package com.beici.waterghost;

import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.beici.waterghost.mapper.nodeMapper;
import com.beici.waterghost.mapper.userMapper;
import com.beici.waterghost.model.classBox.classboxNode;
import com.beici.waterghost.model.idRandom;
import com.beici.waterghost.model.node;
import com.beici.waterghost.model.user;
import com.beici.waterghost.service.classBoxInterface.classBoxNodeService;
import com.beici.waterghost.service.impl.nodeServiceImpl;
import com.beici.waterghost.service.impl.userServiceImpl;
import com.beici.waterghost.service.userService;
import org.apache.catalina.connector.Response;
import org.apache.http.HttpResponse;
import org.jsoup.Jsoup;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.file.Files;
import java.sql.Connection;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

@SpringBootApplication
@MapperScan(basePackages="com.beici.waterghost")
@ServletComponentScan("com.beici.filter")
public class WaterghostApplication{

	public static void main(String[] args) throws IOException {

		System.out.println("                .-\"\"\"-.\n" +
				"               / .===. \\\n" +
				"               \\/ 6 6 \\/\n" +
				"               ( \\___/ )\n" +
				"  _________ooo__\\_____/_____________\n" +
				" /                                  \\\n" +
				" |     waterghost  app  start ! ! !  |\n" +
				" |     © waghost.com 2022-2025		 |\n"+
				" \\_______________________ooo________/ \n" +
				"                |  |  |\n" +
				"                |_ | _|\n" +
				"                |  |  |\n" +
				"                |__|__|\n" +
				"                /-'Y'-\\\n" +
				"               (__/ \\__)\n");


		ConfigurableApplicationContext run = SpringApplication.run(WaterghostApplication.class, args);
		nodeMapper bean = run.getBean(nodeMapper.class);
		// 遍历 文案
		BufferedReader bf = new BufferedReader(new FileReader("C:\\Users\\白\\Desktop\\新建 文本文档 (3).txt"));
		// 遍历 图片
		File f = new File("C:\\Users\\白\\Desktop\\images");
		File[] files = f.listFiles();
		// 每个files 都是一个文件夹
		for (File file : files) {
			File[] files1 = file.listFiles();
			// 每个files1 都是一张图片
			String Images = "";
			for (File file1 : files1) {
				Images+="https://waterghost.oss-cn-shenzhen.aliyuncs.com/root/"+file.getName()+"/"+file1.getName()+",";
			}
			Images=Images.substring(0,Images.length()-1);
			// 入库
			node node = new node();
			node.setNodeId(idRandom.getLongRandom());
//			node.setNodeMess(bf.readLine());
			node.setNodeIp("127.0.0.1");
			node.setUserId(1);
			node.setNodeTag("2000");
			node.setNodeCommentFlag(true);
			node.setNodeTime(new Date());
			node.setNodeImages(Images);
			bean.insert(node);
		}

	}
}
